package com.example.caimogu.fragmentImpl;

import android.util.Log;

import com.example.caimogu.Goods2Json.JsonUtil;
import com.example.caimogu.Goods2Json.PicDataManager;
import com.example.caimogu.bean.Goods;
import com.example.caimogu.http.HttpClientUtil;

import org.json.JSONException;

import java.io.File;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by Caimogu on 2016/4/21.
 */
public class MyStoreImpl {

    public void addNewGoodsImpl(List<Goods> gl,List<String> fileListParent){
        Log.i("caimogu", "MyStore....addNewGoods()");

        HttpClientUtil httpClientUtil = new HttpClientUtil();
        JsonUtil jsonUtil = new JsonUtil();
        PicDataManager picDataManager = new PicDataManager();
        List<String> fileStringListParent = new ArrayList<String>();


        for(String list:fileListParent){

                try {
                    File file = new File(list);
                    String str = picDataManager.file2String(file, null);
                    fileStringListParent.add(str);
                }catch (Exception e){
                    e.printStackTrace();
                }


        }

        //httpClientUtil.sendNewGoods2Server(goods2JsonUtil.getGoodsJson(goods),fileStringList,goods.getPicPath());
        try {
            httpClientUtil.sendNewGoods2Server(jsonUtil.listGoods2JSON(gl),fileStringListParent,gl);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.i("caimogu", "MyStore....addNewGoods()");

    }
}
